/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/
#pragma once

class kText;
class kFont;

#include "krenderable.h"
#include "kmath.h"
#include "kblend.h"

class kText : public kRenderable {
private:
	kEngine* _engine;
	const kFont* _font;
	kColor _diffuse;
	std::tstring _text;
	kAABB _aabb;
	bool _hasTextChanged;
	kBlend _blend;

	void updateAABB();

public:
	kText(kEngine* engine);
	~kText();

	inline void setBlend(const kBlend& blend) {
		_blend = blend;
	}
	inline void setBlend(keBlendFactor src, keBlendOp op, keBlendFactor dst) {
		_blend = kBlend(src, op, dst);
	}
	inline void setBlend(keBlendFactor src, keBlendOp op, keBlendFactor dst, keBlendFactor srcAlpha, keBlendOp opAlpha, keBlendFactor dstAlpha) {
		_blend = kBlend(src, op, dst, srcAlpha, opAlpha, dstAlpha);
	}
	inline const kBlend& getBlend() {
		return _blend;
	}
	inline void setDiffuse(const kColor& diffuse) {
		_diffuse = diffuse;
	}
	inline const kColor& getDiffuse() {
		return _diffuse;
	}
	inline void setText(const std::tstring& text) {
		_text = text;

		_hasTextChanged = true;
	}
	inline void setFont(const kFont* font) {
		_font = font;
	}
	inline const std::tstring& getText() {
		return _text;
	}
	inline const kFont* getFont() {
		return _font;
	}
	inline const kAABB& getAABB() {
		if (_hasTransformChanged || _hasTextChanged)
			updateAABB();

		return _aabb;
	}
	virtual void render(kGraphics* graphics);
};
